package br.inf.solutions.apresentacoes.ssp.control.validator;

import java.util.Date;
import java.util.Map;

import br.com.vexillum.util.DateCalc;
import br.com.vexillum.util.Return;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.items.TransferReserve;

public class TransferReserveValidator extends BaseValidator {

	public TransferReserveValidator(Map<String, Object> mapData) {
		super(mapData);
	}
	
	@Override
	public Return validateSave() {
		Return ret = super.validateSave();
		if(ret.isValid())
			ret.concat(validateDateReserve());
		return ret;
	}
	
	public Return validateDateReserve(){
		Return ret = new Return(true);
		TransferReserve transfer = (TransferReserve) entity;
		Date date1 = DateCalc.incrementDateInDays(transfer.getDateReserve(), 1);
		Date date2 = new Date();
		if(date2 != null){
			if(date1.before(date2)){
				ret.concat(creatReturn("dateReserve", getValidationMessage(null, "datereserve", false)));
			}
		}
		return ret;
	}
}
